/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Table;

import Boundary.Guru;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author masdonzdulz
 */
public class GuruTabelModel extends AbstractTableModel{
    private List<Guru> gr = new ArrayList<Guru>();

    public GuruTabelModel(List<Guru> gr) {
        this.gr = gr;
    }

    public int getRowCount() {
        return this.gr.size();
    }

    public int getColumnCount() {
        return 3;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Guru g = gr.get(rowIndex);

        switch (columnIndex)
        {
            case 0: return g.getNis().getNIS();
            case 1: return g.getNama().getNama();
            case 2: if (g.getKodekehadiran().getKodekehadiran() == 1) {
                return "Masuk";
            }  if (g.getKodekehadiran().getKodekehadiran() == 2) {
                return "Ijin";
            }  if (g.getKodekehadiran().getKodekehadiran() == 3) {
                return "Sakit";
            } if (g.getKodekehadiran().getKodekehadiran() == 4) {
                return "Tidak Hadir";
            };
            default: return "";
        }
    }

    @Override
    public String getColumnName(int columnIndex){
        switch (columnIndex){
            case 0: return "NIS";
            case 1: return "Nama";
            case 2: return "Status";
            default: return "";
        }
    }
}
